package com.traval.util;

import java.sql.Timestamp;

import org.hibernate.Session;
import org.hibernate.Transaction;

import com.traval.goods.models.TGoods;
import com.traval.orderANDcart.models.TOrder;
import com.traval.orderANDcart.models.TOrderInfo;
import com.traval.user.models.TUser;

public class test_02 {

	public static void main(String[] args) {
//		TUser u1 = new TUser();
//		TCart c = new TCart();
		TOrder o = new TOrder();
		TOrderInfo oi = new TOrderInfo();
		
		o.setCreateTime(new Timestamp(11));
		o.setOrderStatus("未支付");
		o.setPrice(100.5);
//		
//		c.setPrice(222.9);
		
//		u1.setAddress("北京理工大学");
//		u1.setEmail("pss@126.com");
//		u1.setPassword("asd123");
//		u1.setRealname("lujinxiao");
//		u1.setTelephone("13113131");
//		u1.setType(1);
//		u1.setUsername("ps");
//		u1.getTOrders().add(o);
//		u1.setTCart(c);

		Session session = HibernateSessionFactory.getSession();
		Transaction tx = session.beginTransaction();
		oi.setGoods((TGoods)session.get(TGoods.class, 2));
		o.getTOrderinfos().add(oi);
		o.setTUser((TUser)session.get(TUser.class, 3));
		session.save(o);
		tx.commit();
		HibernateSessionFactory.closeSession();
	}

}
